package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import news.*;

public class UpdateTopicServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doPost(request, response);
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter out = response.getWriter();
		long tid = Long.parseLong(request.getParameter("tid"));
		String tname = request.getParameter("uptopic");
		Topic t = new Topic();
		t.setTid(tid);
		t.setTname(tname);
		int re = TopicDao.dao.updateTopic(t);
		request.setAttribute("result", re);
		request.getRequestDispatcher("WEB-INF/jsp/updateTopic.jsp").forward(
				request, response);
	}
}
